<template>
	<view class="bulletin">
		<p-navbar  :title="type=='0'?'公开课程':'币圈热点'"></p-navbar>
		<scroll-view @scrolltolower="reachBottom" :scroll-y="true" class="scroll">
		<view class="bulletin-content">
			<view class="bulletin-item flex" v-for="(item,index) in bulletinList" :key="index" @tap="nav(item)">
				<view class="bulletin-left">
					<image :src="item.pic" mode="aspectFill"></image>
				</view>
				<view class="bulletin-right">
					<view class="bulletin-text">
						{{item.title}}
					</view>
					<view >
						<text style="color: #FE485A;font-size: 24rpx;" v-if="type==0">免费</text>
						<view class="crux flex align-items">
							<view  v-for="(crux,indexs) in item.tagStrList" :key="indexs" class="ctext">{{crux}}</view>
						</view>
					</view>
					<view class="bulletin-readNumber flex align-items justify-between">
						<view class="">
							诸葛量化
						</view>
						<view class="">
							{{item.issueTime}}
						</view>
					</view>
				</view>
			</view>
		</view>
		</scroll-view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				bulletinList:[
					// {
					// 	content:'零基础带你玩转量化交易策略交易',
					// 	time:'2021/02/19 12:00',
					// },
					// {
					// 	content:'零基础带你玩转量化交易策略交易',
					// 	time:'2021/02/19 12:00',
					// }
				],
				page:'1',
				videoType:'3',
				crux:[]
			}
		},
		methods: {
			nav(item){
				if(this.type=='0'){
					this.$Router.push({ 
						path:'/pages/college/course-item',
						query:{
							data:JSON.stringify(item),
							type:JSON.stringify(this.type)
						}
					})
					// this.$Router.push({ path: '/pages/transaction/details',query:{type:JSON.stringify(item)}})
				}else{
					this.$state.article = item.id
					uni.navigateTo({
						url:"./notice?types=1&id="+item.id
					})
				}
			},
			video(){
				if(this.type=='0'){
					this.request.post('getInformationByType?infoType='+this.videoType+'&page='+this.page+'&pageSize=20', {
					}).then(res=>{
						this.bulletinList.push(...res.data.data)
						
					})
				}else{
					this.request.post('getInformationList?infoType='+this.videoType+'&page='+this.page+'&pageSize=20', {
					}).then(res=>{
						this.bulletinList.push(...res.data.data)
						for(let i=0;i<this.bulletinList.length;i++){
							if(this.bulletinList[i].tagStrList){
							this.bulletinList[i].tagStrList=this.bulletinList[i].tagStrList.slice(0,3)	
							}
							
							
						}
					})
				}
				
			},
			//下拉
			reachBottom(){
				this.page++
				if(this.type=='1'){
					this.videoType=2
					this.video()
				}else{
					this.video()
				}
			}
		},
		onLoad(options) {
		  this.type = JSON.parse(options.type);
		  if(this.type=='1'){
		  	this.videoType=2
		  	this.video()
		  }else{
		  	this.video()
		  }
		},
	}
</script>

<style lang="scss">
	.bulletin{
		.bulletin-title{
			font-size: 36rpx;
			font-family: PingFang;
			font-weight: bold;
			// color: #FFFFFF;
			position: relative;
			padding-left: 20rpx;
			text{
				color: #FF8128;
			}
			&::after{
				content: "";
				height: 40rpx;
				border: 2px solid #FF8128;
				position: absolute;
				left: 0;
				top: 0;
				border-radius: 6px;
			}
		}
		.bulletin-content{
			width: 678rpx;
			margin: 34rpx auto 0;
			border-radius: 32rpx;
			// background: rgba(22, 119, 255, 0.05);
			// padding: 40rpx;
			box-sizing: border-box;
			
			.bulletin-item{
				height: 210rpx;
				margin-bottom: 36rpx;
				// padding-bottom: 20rpx;
				border-bottom: 1rpx solid $border;
				.bulletin-left{
					width: 240rpx;
					height: 180rpx;
					
					image{
						width: 100%;
						height: 100%;
						border-radius: 16rpx;
					}
				}
				.bulletin-right{
					margin-left: auto;
					width: 388rpx;
					height: 180rpx;
					position: relative;
					.bulletin-text{
						margin-bottom: 22rpx;
						font-size: 28rpx;
						font-family: PingFang;
						font-weight: bold;
						// color: #FFFFFF;
						display: -webkit-box;
						-webkit-box-orient: vertical;
						-webkit-line-clamp: 2;
						overflow: hidden;
					}
					.bulletin-readNumber{
						position: absolute;
						bottom: 0;
						left: 0;
						font-size: 24rpx;
						font-family: PingFang;
						// font-weight: bold;
						// color: rgba(255, 255, 255, 0.3);
						width: 98%;
					}
					.crux{
						position: absolute;
						bottom: 45rpx;
						left: 0;
						.ctext{
							margin-right: 10rpx;
							// background: #263749;
							border: 1rpx solid $border;
							border-radius: 4rpx;
							height: 50rpx;
							line-height: 44rpx;
							color: $light-color;
							font-size: 24rpx;
							padding: 0 10rpx;
						}
					}
				}
				&:last-child{
					margin-bottom: 0;
				}
			}
		}
		.scroll {
			height: calc(100vh - 0rpx - var(--status-bar-height));
		}
	}
</style>
